// server/routes/reviews.js
const express = require('express');
const router = express.Router();
const ctrl = require('../ctrls/reviews');
const multer = require('multer');
const path = require('path');

var storage = multer.diskStorage({
    destination: (req, file, cb) => {
        cb(null, './public/reviews/');
    },
    filename: (req, file, cb) => {
        let ext = path.extname(file.originalname);
        cb(null, Date.now() + ext);
    }
});
var upload = multer({ storage: storage });

router.post('/reviewsBygid', ctrl.reviewsBygid);
router.post('/addReview', upload.array('images', 9), ctrl.addReview); // 处理多个文件
router.post('/userReviews', ctrl.userReviews);
router.post('/updatereviews', ctrl.updatereviews);
router.post('/addreviews', ctrl.addreviews);
router.post('/delreviews', ctrl.delreviews);

module.exports = router;
